package com.shenma2009.controller;

import com.shenma2009.service.HBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.Map;

/**
 * @author 军哥
 * @version 1.0
 * @description: TestController
 * @date 2023/5/25 17:56
 */

@RestController
@RequestMapping(value = "test")
@Slf4j
public class TestController {
    @Resource
    HBaseService hBaseService;

    @GetMapping(value = "/test1")
    void createTable() throws IOException {
        hBaseService.createTable("test","Column Family 1","Column Family 2");
        hBaseService.insertOrUpdate("test","1","Column Family 1","测试key1","测试key1");
        hBaseService.insertOrUpdate("test","2","Column Family 2","测试key2","测试key2");
    }
    @GetMapping(value = "/test2")
    void getResultScanner() throws IOException {
        Map<String, Map<String, String>> test = hBaseService.getResultScanner("test");
        test.forEach((k,v)->{
            log.info("key为:{},value为:{}",k,v);
        });
    }
    @GetMapping(value = "/test3")
    void deleteTable() throws IOException {
        hBaseService.deleteTable("test111");
    }

}
